package com.tbit.uqbike.object.pojo.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.tbit.uqbike.annos.Excel;
import com.tbit.uqbike.constant.CsvConstant;
import com.tbit.uqbike.webmanager.util.csv.annotations.Csv;
import com.tbit.uqbike.webmanager.util.csv.annotations.Sum;
import lombok.Data;

import java.util.Date;

/**
 * 分账用户退款明细
 *
 * @Author:BUGTian
 * @DATE: 2022/5/30
 */
@Data
public class SubAccountUserRefundVO {

    /**
     * 支付平台订单号
     */
    @Excel(name = "汇付订单号", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 14)
    @Csv(name = "汇付订单号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String paymentId;

    /**
     * 时间
     */
    @Excel(name = "日期", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 1)
    @Csv(name = "日期", type = CsvConstant.CSV_TYPE_WITHOUT)
    private Date refundTime;

    /**
     * 区域id
     */
    private Integer accountId;

    /**
     * 订单编号
     */
    @Excel(name = "订单编号", sort = 3)
    @Csv(name = "订单编号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String buyOrderNO;


    /**
     * 商户编号
     */
    @Excel(name = "商户订单编号", sort = 13)
    @Csv(name = "商户订单编号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String confirmId;

    /**
     * 订单类型
     */
    @Excel(name = "订单类型", readConverterExp = "-1=押金,0=充值,1=免押卡,2=骑行卡,3=充值结束订单,4=vip会员卡,5=优惠券套餐,7=欠款补交", sort = 4)
    @Csv(name = "订单类型", keys = {"-1", "0","1", "2","3", "4","5","7"}, values = {"押金", "充值","免押卡", "骑行卡","充值结束订单", "vip会员卡","优惠券套餐","欠款补交"}, type = CsvConstant.CSV_TYPE_WITHOUT)
    private Integer buyOrderType;

    /**
     * 订单时间
     */
    @Excel(name = "订单时间", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 5)
    @Csv(name = "订单时间", type = CsvConstant.CSV_TYPE_WITHOUT)
    private Date addTime;

    /**
     * 退款金额
     */
    private Integer refundMoney;

    /**
     * 退平台服务费
     */
    private Integer serviceFeeTotal;

    /**
     * 分账退款金额
     */
    private Integer adaPayRefundTotal;

    /**
     * 账号
     */
    @Excel(name = "用户编号", dateFormat = "yyyy-MM-dd HH:mm:ss", sort = 15)
    @Csv(name = "用户编号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String userNO;

    /**
     * 退款比例
     */
    private Double proportion;

    /**
     * 应退款金额
     */
    private Integer shouldRefundMoney;

    /**
     * 退汇付手续费
     */
    private Integer refundFee;

    /**
     * 汇付退款
     */
    private Integer adaPayRefund;

    /**
     * 其他平台退款
     */
    private Integer orderRefund;


    /**
     * ===以下是导出相关转换===
     */
    @JSONField(serialize = false)
    @Excel(name = "区域", sort = 2)
    @Csv(name = "区域", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String areaName;

    @Excel(name = "账号", sort = 9)
    @Csv(name = "账号", type = CsvConstant.CSV_TYPE_WITHOUT)
    private String nickName;

    @JSONField(serialize = false)
    @Excel(name = "退款金额", sort = 6)
    @Csv(name = "退款金额", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String refundMoneyYuan;

    @JSONField(serialize = false)
    @Excel(name = "退平台服务费(所有平台汇总)", sort = 7)
    @Csv(name = "退平台服务费(所有平台汇总)", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String serviceFeeTotalYuan;

    @JSONField(serialize = false)
    @Excel(name = "分账退款金额(所有平台汇总)", sort = 8)
    @Csv(name = "分账退款金额(所有平台汇总)", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String adaPayRefundTotalYuan;



    @JSONField(serialize = false)
    @Excel(name = "应退款金额", sort = 10)
    @Csv(name = "应退款金额", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String shouldRefundMoneyYuan;

    @JSONField(serialize = false)
    @Excel(name = "退汇付手续费", sort = 11)
    @Csv(name = "退汇付手续费", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String refundFeeYuan;

    @JSONField(serialize = false)
    @Excel(name = "汇付退款", sort = 12)
    @Csv(name = "汇付退款", type = CsvConstant.CSV_TYPE_WITHOUT)
    @Sum
    private String adaPayRefundYuan;

    /**
     * 单位转换
     */
    public void unitConversion() {
        this.refundMoneyYuan = String.format("%.2f", ((double) refundMoney / 100D));
        this.serviceFeeTotalYuan = String.format("%.2f", ((double) serviceFeeTotal / 100D));
        this.adaPayRefundTotalYuan = String.format("%.2f", ((double) adaPayRefundTotal / 100D));
        this.shouldRefundMoneyYuan = String.format("%.2f", ((double) shouldRefundMoney / 100D));
        this.refundFeeYuan = String.format("%.2f", ((double) refundFee / 100D));
        this.adaPayRefundYuan = String.format("%.2f", ((double) adaPayRefund / 100D));
    }
}
